package com.koudejun.cms.configure;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ImageConfig implements WebMvcConfigurer {

    @Value("${web.upload}")
    private String path;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        System.out.println("图片上传路径==========="+path);
        //路径前面要使用file协议，本地路径使用/分隔
        registry.addResourceHandler("/img/**").addResourceLocations("file:"+path);
    }
}
